 var settings = null;
 settings = {
 width: "auto",
 height: "auto",
 sizeIncludesBars: true,
 sizeIncludesPanels: true,
 statusBar: true,
 htmlareaPaste: false,
 mozParaHandler: "best",
 getHtmlMethod: "DOMwalk",
 undoSteps: 20,
 undoTimeout: 500,
 changeJustifyWithDirection: false,
 fullPage: false,
 pageStyle: "",
 baseHref: null,
 expandRelativeUrl: true,
 stripBaseHref: true,
 stripSelfNamedAnchors: true,
 only7BitPrintablesInURLs: true,
 sevenBitClean: false,
 killWordOnPaste: true,
 makeLinkShowsTarget: true,
 flowToolbars: true,
 stripScripts: false,
 CharacterMapMode: "popup",
 ListTypeMode: "toolbar",
 showLoading: false,
 showChar: true,
 showWord: true,
 showHtml: true
 };


 function getCookieVal (offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1)
 endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
 }

 function getCookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen) {
 var j = i + alen;
 if (document.cookie.substring(i, j) == arg)
 return getCookieVal (j);
 i = document.cookie.indexOf(" ", i) + 1;
 if (i == 0) break;
 }
 return null;
 }

 function setCookie (name, value) {
 var argv = setCookie.arguments;
 var argc = setCookie.arguments.length;
 var expires = (argc > 2) ? argv[2] : null;
 var path = (argc > 3) ? argv[3] : null;
 var domain = (argc > 4) ? argv[4] : null;
 var secure = (argc > 5) ? argv[5] : false;
 document.cookie = name + "=" + escape (value) +
 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
 ((path == null) ? "" : ("; path=" + path)) +
 ((domain == null) ? "" : ("; domain=" + domain)) +
 ((secure == true) ? "; secure" : "");
 }

 function _onResize() {
 var sHeight;
 if (window.innerHeight) sHeight = window.innerHeight;
 else if (document.body && document.body.offsetHeight) sHeight = document.body.offsetHeight;
 else return;
 if (sHeight>270) {
 sHeight = sHeight - 245;
 }

 else {
 sHeight = 30
 }
 var div = document.getElementById("div_plugins");
 div.style.height = sHeight + "px";
 }


function Dialog(url, action, init)
 {
 if (typeof init == "undefined") {
 init = window; // pass this window object by default
 }
 Dialog._geckoOpenModal(url, action, init);
 };


Dialog._parentEvent = function(ev)
{
 setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
 if (Dialog._modal && !Dialog._modal.closed) {
 agt = navigator.userAgent.toLowerCase();
 is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
 if (is_ie) {
 ev.cancelBubble = true;
 ev.returnValue = false;
 } else {
 ev.preventDefault();
 ev.stopPropagation();
 }
 }
};


// should be a function, the return handler of the currently opened dialog.
Dialog._return = null;

// constant, the currently opened dialog
Dialog._modal = null;

// the dialog will read it's args from this variable
Dialog._arguments = null;

Dialog._geckoOpenModal = function(url, action, init) {
 var dlg = window.open(url, "hadialog",
 "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
 "scrollbars=no,resizable=yes,modal=yes,dependable=yes");
 Dialog._modal = dlg;
 Dialog._arguments = init;

 // capture some window's events
 function capwin(w) {
// Xinha._addEvent(w, "click", Dialog._parentEvent);
// Xinha._addEvent(w, "mousedown", Dialog._parentEvent);
// Xinha._addEvent(w, "focus", Dialog._parentEvent);
 };
 // release the captured events
 function relwin(w) {
// Xinha._removeEvent(w, "click", Dialog._parentEvent);
// Xinha._removeEvent(w, "mousedown", Dialog._parentEvent);
// Xinha._removeEvent(w, "focus", Dialog._parentEvent);
 };
 capwin(window);
 // capture other frames
 for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
 // make up a function to be called when the Dialog ends.
 Dialog._return = function (val) {
 if (val && action) {
 action(val);
 }
 relwin(window);
 // capture other frames
 for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
 Dialog._modal = null;
 };
};

 function fExtended () {
 Dialog("Extended.html", function(param) {
 if(param) {
 settings.width = param["width"];
 settings.height = param["height"];
 settings.sizeIncludesBars = (param["sizeIncludesBars"]=="true");
 settings.sizeIncludesPanels = (param["sizeIncludesPanels"]=="true");
 settings.statusBar = (param["statusBar"]=="true");
 settings.htmlareaPaste = (param["htmlareaPaste"]=="true");
 settings.mozParaHandler = param["mozParaHandler"];
 settings.getHtmlMethod = param["getHtmlMethod"];
 settings.undoSteps = param["undoSteps"];
 settings.undoTimeout = param["undoTimeout"];
 settings.changeJustifyWithDirection = (param["changeJustifyWithDirection"]=="true");
 settings.fullPage = (param["fullPage"]=="true");
 settings.pageStyle = param["pageStyle"];
 settings.baseHref = param["baseHref"];
 settings.expandRelativeUrl = (param["expandRelativeUrl"]=="true");
 settings.stripBaseHref = (param["stripBaseHref"]=="true");
 settings.stripSelfNamedAnchors = (param["stripSelfNamedAnchors"]=="true");
 settings.only7BitPrintablesInURLs = (param["only7BitPrintablesInURLs"]=="true");
 settings.sevenBitClean = (param["sevenBitClean"]=="true");
 settings.killWordOnPaste = (param["killWordOnPaste"]=="true");
 settings.makeLinkShowsTarget = (param["makeLinkShowsTarget"]=="true");
 settings.flowToolbars = (param["flowToolbars"]=="true");
 settings.stripScripts = (param["stripScripts"]=="true");
 settings.CharacterMapMode = param["CharacterMapMode"];
 settings.ListTypeMode = param["ListTypeMode"];
 settings.showLoading = (param["showLoading"]=="true");
 settings.showChar = (param["showChar"]=="true");
 settings.showWord = (param["showWord"]=="true");
 settings.showHtml = (param["showHtml"]=="true");
 }

 
  }, settings );
 }

 function init(){
 var co = getCookie('co_ext_Xinha');
 if(co!=null){
 var co_values;
 var co_entries = co.split('###');
 alert("co-value"+co_entries);

 for (var i in co_entries) {
 co_values = co_entries[i].split('=');
 if(co_values[0]=='plugins') {
 for(var x = 0; x < document.forms[0].plugins.length; x++) {
 if(co_values[1].indexOf(document.forms[0].plugins[x].value)!=-F1) {
 document.forms[0].plugins[x].checked = true;
 }
 }
 } else if(co_values[0]!='') {
 document.getElementById(co_values[0]).value = co_values[1];
 }
 }
 }
 _onResize();
 };

 window.onresize = _onResize;
 window.onload = init;